import axios from 'axios'
const student = {
     state :{
        stdLists:[]
     },
     mutations:{
        getStudentData(state,arr){
            state.stdLists = arr
        }
     },
     actions:{
        addStudData({commit},obj){
            return axios.post('http://localhost/api.php/decide',obj)
            .then( res =>{
                console.log(res.data)
            })
        },
        // 得到所有已交卷学生的信息
        getStdDataAll({commit},uid){
            return axios.get('http://localhost/api.php/decide',{
                params:{
                    transform:1,
                    order:'id',
                    filter:'uid,cs,'+uid
                }
            })
            .then( res =>{
                console.log(res.data.decide)
               commit('getStudentData',res.data.decide)
            })
            .catch( err=>{
                console.log(err)
            })
        },
        // 上传学生成绩  修改
        updateStdData({commit},obj){
            //console.log(id,count)
            return axios.put('http://localhost/api.php/decide/'+obj.id,{grade:obj.count})
                    .then( res =>{
                            //console.log(id,count)
                    })
                    .catch( err =>{
                        console.log(err)
                    })
        }
     }
}
export default student